Skip to content

Improved trace method#336

Open
Poseclop wants to merge 2 commits intodbfannin:masterfrom
Poseclop:improved-trace-method
Open

Improved trace method#336
Poseclop wants to merge 2 commits intodbfannin:masterfrom
Poseclop:improved-trace-method

Conversation

@Poseclop
Copy link

@Poseclop Poseclop commented Jun 21, 2024

I feel the trace method should keep it's original intent to log the current stack trace (same as node.js defautl console.trace)

  • Looks like some time ago the default behavior of LoggerService.trace was to call console.trace but this was removed as the stack trace shown was the one of console.trace.
  • This PR aims to add back the stack trace, putting it on a higher level so that only 1 extra line is present in the stack trace (LoggerService.trace)
  • If somehow the stack trace is not available, the method will revert to its previous behavior and only log the message and additional params
  • I did not manage to create a unit test that would succefully check the exact stack trace added in _log method so I'm only making sure the message sent to the method is present in the stack trace. Maybe that can be improved
  • Watchout, this change will obviously drastically change the output in console if users where using a lot of LoggerService.trace calls.

image

@bmtheo
Copy link
Collaborator

bmtheo commented Jul 11, 2025

After some analysis, this is not ok because message can be an object or a function but you could maybe come back to console.trace in write.service.ts
This adds some lines about ngx logger engine but is not an issue as long as we have the user code at some point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants